package com.haiyu.manager.controller.platform;

import com.haiyu.manager.pojo.UserAddressInfo;
import com.haiyu.manager.response.PageDataResult;
import com.haiyu.manager.service.AddressInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("addressInfo")//指定路由
public class AddressInfoController {
    @Autowired
    AddressInfoService addressInfoService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     *
     * 功能描述: 分页查询AddressInfo列表
     *
     *
     */
    @RequestMapping(value = "/getAddressInfoList", method = RequestMethod.POST)
    @ResponseBody
    public PageDataResult getAddressInfoList(@RequestParam("pageNum") Integer pageNum,
                                                  @RequestParam("pageSize") Integer pageSize,@RequestParam("buyerOpenid") String buyerOpenid){

        System.out.println(buyerOpenid);
        PageDataResult pdr = new PageDataResult();
        try {
            if(null == pageNum) {
                pageNum = 1;
            }
            if(null == pageSize) {
                pageSize = 10;
            }
            // 获取用户列表
            pdr = addressInfoService.getUserAddressInfo(buyerOpenid, pageNum ,pageSize);
            logger.info("addressInfo列表查询=pdr:" + pdr);

        } catch (Exception e) {
            e.printStackTrace();
            logger.error("addressInfo列表查询异常！", e);
        }
        return pdr;

    }
}
